package com.fau.om.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.om.action.PublicAction;
import com.fau.om.entity.MedicalAdmin;
import com.fau.om.entity.MedicalOrders;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc 平台的订单审核Action
 * @author suny
 * @datetime 2014年9月15日,上午10:29:21
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class PlatformAuditAction extends PublicAction implements ModelDriven<MedicalOrders>{

	private static final long serialVersionUID = 1L;
	private MedicalOrders orders = new MedicalOrders();
	
	/**
	 * @desc  平台订单审核跳转，界面 
	 * @return
	 * @author suny
	 * @datetime 2014年9月15日,上午10:13:27
	 */
	@Action(value = "platform_audit_init", results = {@Result(name = SUCCESS, location = "platform_audit_init.jsp")})
	public String init() {
		return SUCCESS;
	}
	
	/**
	 * @desc 查询本平台未审核订单
	 * @return
	 * @author suny
	 * @datetime 2014年9月15日,上午10:16:36
	 */
	@Action(value = "platform_audit_view")
	public String view() {
		HttpServletResponse response = ServletActionContext.getResponse();
		map = ServletActionContext.getContext().getParameters();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		pageBean = this.baseAllService.getAuditManagerService().findPlatformPendingOrders(orders, map, admin);
		map.clear();
		map.put("total", pageBean.getTotalRow());
		map.put("data", pageBean.getResult());
		formatJSON(response, map);
		return null;
	}
	
	/**
	 * @desc 打开平台，订单跟踪信息界面
	 * @return null
	 * @author suny
	 * @datetime 2014年9月27日,下午6:54:18
	 */
	@Action(value = "platform_trace_detail_init",results = {@Result(name = SUCCESS,location="platform_trace_detail_init.jsp")})
	public String traceInit() {
		return SUCCESS;
	}

	/**
	 * @desc 加载平台，订单跟踪信息界面数据
	 * @return null
	 * @author dangjh
	 * 2015年2月14日 下午4:06:51
	 */
	@Action(value = "platform_trace_detail_view")
	public String traceView() {
		HttpServletResponse response = ServletActionContext.getResponse();
		list = this.baseAllService.getAuditManagerService().findOrdersLogByNo(orders.getSerialNum());
		formatJSON(response, list);
		return null;
	}
	
	@Override
	public MedicalOrders getModel() {
		return orders;
	}
	
}
